# coding=utf8
'''
Created on 2014年8月4日

@author: hongxingfan
@summary: 用于截取url字段的工具类
'''
import time

class UrlUtil:
    
    format = "%Y-%m-%d %H:%M:%S"
    
    def __init__(self, url):
        url = url.strip()
        cols = url.split("\t")  # tab=4个空格
        
        self.time = time.strftime(self.format, time.localtime(float(cols[0])))
        self.ip = cols[1]
        self.region = cols[2]
        self.suv = cols[3]
        self.domain = cols[4]
        self.url = cols[5]
        self.columnid = cols[6]
        self.channelid = cols[7]
        self.refer = cols[8]
        self.refer_type = cols[9]
        self.refer_column = cols[10]
        self.refer_channel = cols[11]
        self.userid = cols[12]
        self.lastuserid = cols[13]
        self.yyid = cols[14]
        self.zdomain = cols[15]
        self.screen = cols[16]
        self.os = cols[17]
        self.browser = cols[18]
        self.bkernel = cols[19]
        # self.json = cols[20]
    
    def isRightful(self):
        if "wmh-auto-tab" in self.url:
            return False
        return True
        
    def __unicode__(self):
        pass

if __name__ == "__main__":
    url = "1396442439    114.251.186.8    CN1100    000008DB3C247D3E64730123669DB689    db.auto.sohu.com    /searchterm.sip    37    13    www.sohu.com    11    4    0    -    -    000008DB3C247D3E64730123669DB689    -    0    2    1    3    {\"mb\":0, \"mbOs\" : 0, \"page_type\": \"0\", \"etc_data\": \"200390431;242870036;260978504;397643186\"}\n"        
    u = UrlUtil(url)
    print("%s\t%s\t%s" % (u.time, u.browser, u.json)),
